# -*- coding:utf-8 -*-
# @FileName  :dhcc_first_page.py
# @Time      :2020/12/14 15:49
# @Author    :Zhoujirong
# @Desc      : 首页公共接口
import parameterized
from biz.cases.base_case import BaseCase
from common.log import Log
from biz.flow.first_page import FirstPageRequest
from common.params_operator import Param
class TestFirstPage(BaseCase):
    data_file_name = 'first_page.yaml'
    @classmethod
    def setUpClass(cls):
        cls.cookie = BaseCase().get_token()

    @parameterized.parameterized.expand(Param.from_excel('system_version_data.xls'))
    def test_get_version(self,param,check,desc):
        '''获取版本号'''
        self._testMethodDoc = desc
        ret = FirstPageRequest.get_version(param,self.cookie)
        Log.info(ret)
        self.assertIn(check,ret)

    @parameterized.parameterized.expand(Param.from_excel('menu_id_data.xls'))
    def test_get_menu(self,sysNo,check,desc):
        self._testMethodDoc = desc
        ret = FirstPageRequest.get_menu(sysNo,self.cookie)
        Log.info(ret)
        self.assertEqual(check,ret.data[0].data.name)

    def test_get_menu_root(self):
        '''获取子系统名称'''
        ret = FirstPageRequest.get_menu_root(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret.menu)

    def test_get_home(self):
        '''获取主页'''
        ret = FirstPageRequest.get_home(self.cookie)
        Log.info(ret)
        self.assertIn('主页',ret)

    def test_get_nick_by_username(self):
        '''获取所有用户的昵称'''
        ret = FirstPageRequest.get_nick_by_username(self.cookie)
        Log.info(ret)
        check = self.file_data.get('nickName')
        self.assertEqual(check,ret.zjr)

    def test_get_platprojectname(self):
        '''获取平台包名称'''
        ret = FirstPageRequest.get_platprojectname(self.cookie)
        Log.info(ret)
        self.assertEqual('/creditplatformweb/',ret)

    def test_current_user(self):
        '''当前用户信息'''
        ret = FirstPageRequest.get_current_user(self.cookie)
        Log.info(ret)
        check1 = self.file_data.get('userName')
        check2 = self.file_data.get('nickname')
        self.assertEqual(check1,ret.userName)
        self.assertEqual(check2,ret.nickname)

    def test_get_notice(self):#需要先添加通知
        '''主页的通知'''
        curPage = 1
        maxSize = 5
        ret = FirstPageRequest.get_notice(curPage,maxSize,self.cookie)
        Log.info(ret)
        self.assertEqual({},ret.paramsMap)










if __name__ == "__main__":
    pass